﻿using System;
using System.Runtime.Serialization;
using MugenMvvmToolkit.Interfaces;

namespace MugenMvvmToolkit.Models
{
    /// <summary>
    ///     Provides data for the error changed event.
    /// </summary>
#if WPF
    [Serializable]
#endif
    [DataContract]
    public class DataErrorsChangedMessage : IStateChangedMessage
    {
        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="DataErrorsChangedMessage" /> class.
        /// </summary>
        /// <param name="propertyName">
        ///     The name of the property that has an error.  null or <see cref="F:System.String.Empty" /> if the error is object-level.
        /// </param>
        /// <param name="isAsyncValidate">Indicates that property was async validation.</param>
        public DataErrorsChangedMessage(string propertyName, bool isAsyncValidate)
        {
            PropertyName = propertyName;
            IsAsyncValidate = isAsyncValidate;            
        }

        #endregion

        #region Properties

        /// <summary>
        ///     Gets the name of the property that has an error.
        /// </summary>
        /// <returns>
        ///     The name of the property that has an error. null or <see cref="F:System.String.Empty" /> if the error is object-level.
        /// </returns>
        public string PropertyName { get; private set; }

        /// <summary>
        ///     Indicates that property was async validated.
        /// </summary>
        public bool IsAsyncValidate { get; private set; }

        #endregion
    }
}